﻿<%@ Control Language="C#" Inherits="VioletDevelopmentLaboratory.Net.Web.UserControlBase" %>
<%@ Import Namespace="System.Net.Mail" %>

<script runat="server">
	protected void SendButton_Click(object sender, EventArgs e)
	{
		SmtpClient smtp = new SmtpClient();

		try
		{
			smtp.Send(FromTextBox.Text, VWebConfigurationReader.Administrator.Email, SubjectTextBox.Text, BodyTextBox.Text);

			VUtility.ShowMessagePanel(Page, "Success!!!", true);

			FromTextBox.Text = "";
			SubjectTextBox.Text = "";
			BodyTextBox.Text = "";
		}
		catch
		{
			VUtility.ShowMessagePanel(Page, "Failure!!!", true);
		}
	}
</script>

<fieldset style="padding : 15px;">
	<legend>To Administrator</legend>
	<p>
		From
		<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
			ControlToValidate="FromTextBox" Display="Dynamic" 
			ErrorMessage="*"></asp:RequiredFieldValidator>
		<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
			ErrorMessage="* Invalid Email Address" Display="Dynamic" 
			ControlToValidate="FromTextBox" 
			ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
		<br />
		<asp:TextBox ID="FromTextBox" runat="server" Columns="60"></asp:TextBox>
	</p>
	<p>
		Subject
		<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
			ControlToValidate="SubjectTextBox" Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
		<br />
		<asp:TextBox ID="SubjectTextBox" runat="server" Columns="60"></asp:TextBox>
	</p>
	<p>
		Body
		<asp:RequiredFieldValidator ID="BodyTextBoxRequiredFieldValidator" runat="server" 
			ControlToValidate="BodyTextBox" Display="Dynamic" ErrorMessage="*"></asp:RequiredFieldValidator>
		<br />
		<asp:TextBox ID="BodyTextBox" runat="server" TextMode="MultiLine" Rows="10" Columns="60"></asp:TextBox><br />
		
	</p>
	<p>
		<asp:Button ID="SendButton" runat="server" Text="Send" onclick="SendButton_Click" />
	</p>
</fieldset>